<%@ page import="br.edu.ufam.avaliacao.Avaliacao" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="layout" content="main" />
<g:javascript library="app/buttons"/>
<g:set var="entityName" value="${message(code: 'avaliacao.label', default: 'Avaliacao')}" />
<title><g:message code="default.list.label" args="[entityName]" /></title>
</head>
<body>

  <div class="nav">
    <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="Início"/></a></span>
    <span class="menuButton"><g:link class="create" action="create"><g:message code="Nova Avaliação" args="[entityName]" /></g:link></span>
  </div>
  <div class="body" style="width: 1000px">
    <h1><g:message code="Lista de Avaliações" /></h1><br>
    <g:if test="${flash.message}">
      <div class="message">${flash.message}</div>
    </g:if>

    <div class="dialog" align="left">
      <g:form name="ajaxForm" action="doSearch" >
        <table class="tabelas" cellpadding="5" cellspacing="1">
          <tr>
            <td valign="top" align="right" width="60"><strong>Curso:</strong></td>
            <td valign="top" class="value">
          <g:select name="curso" from="${br.edu.ufam.academico.Curso.list()}" optionKey="id" value="${avaliacaoInstance?.curso?.id}"  noSelection="['':'']"/>
          </td>
          </tr>

          <tr>
            <td valign="top" align="right"><strong>Avaliador:</strong></td>
            <td valign="top" class="value">
          <g:select name="usuario" 
                    from="${br.edu.ufam.controleAcesso.Usuario.list()}" 
                    optionKey="id"
                    value="${avaliacaoInstance?.usuario?.id}"
                    noSelection="['':'']"                                
                    />
          </td>
          </tr>

          <tr>
            <td valign="top" align="right"><strong>Data Início:</strong></td>
            <td valign="top" class="value">
              <input class="texto" type="text" size="50" id="dateStart" name="dateStart"/>&nbsp;
            </td>

            <td valign="top" align="right"><strong>Data Fim:</strong></td>
            <td valign="top" class="value">
              <input class="texto" type="text" size="50" id="dateEnd" name="dateEnd"/>&nbsp;
            </td>

          </tr>

        </table>
        <br>
        <input id="buscar1" class="botao" type="submit" value="Buscar" />
      </g:form>
      <br/>
      <div id="updateMe" class="tabelas" style="display:none"></div>
    </div>
    <div class="list" >
      <table>
        <thead>
          <tr  id="testDouglas">

        <g:sortableColumn property="curso" title="${message(code: 'avaliacao.curso.label', default: 'Curso')}" />

        <g:sortableColumn property="avaliador" title="${message(code: 'avaliacao.usuario.label', default: 'Avaliador')}" /> 

        <g:sortableColumn property="conceitoFinal" title="${message(code: 'avaliacao.conceitoFinal.label', default: 'Conceito Final')}" /> 

        <g:sortableColumn property="dateStart" title="${message(code: 'avaliacao.dateStart.label', default: 'Data Início')}" /> 

        <g:sortableColumn property="dateEnd" title="${message(code: 'avaliacao.dateEnd.label', default: 'Data Fim')}" /> 

        <g:sortableColumn property="status" title="${message(code: 'avaliacao.status.label', default: 'Status')}" /> 

        </tr>
        </thead>
        <tbody>
        <g:each in="${avaliacaoInstanceList}" status="i" var="avaliacaoInstance">
          <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"  id="testDouglas">

            <td> <g:link action="show" id="${avaliacaoInstance.id}">${fieldValue(bean: avaliacaoInstance, field: "curso.nomeCursoDiploma")}</g:link></td>

          <td>${fieldValue(bean: avaliacaoInstance, field: "usuario")}</td>

          <td>${fieldValue(bean: avaliacaoInstance, field: "conceitoFinal")}</td>

          <td>${avaliacaoInstance.dateStart.format("dd/MM/yyyy")}</td>

          <td>${avaliacaoInstance.dateEnd.format("dd/MM/yyyy")}</td>

          <td><g:if test="${avaliacaoInstance.status=='Coordenador'}">
            <g:link action="show" id="${avaliacaoInstance.id}"><img src="../images/skin/teacher_4.png" width="24" height="24"></g:link>
          </g:if>
          <g:elseif test="${avaliacaoInstance.status=='Em andamento' }">
            <g:link action="show" id="${avaliacaoInstance.id}"><img src="../images/skin/avaliador_3.png" width="24" height="24"></g:link>
          </g:elseif>
          <g:else>
            <g:link action="show" id="${avaliacaoInstance.id}"><img src="../images/skin/finalizado_3.png" width="24" height="24"></g:link>
          </g:else>
          </td>
          </tr>
        </g:each>
        </tbody>
      </table>
    </div>
    <div class="paginateButtons">
      <g:paginate total="${avaliacaoInstanceTotal}" />
    </div>

    <br><br>

    <div style="width: 100% ; text-align: center">                     
      <g:form name="legendaForm" >
        <table class="tabelas" cellpadding="5" cellspacing="1">
          <tr>

            <td  align="center" > <img src="../images/skin/teacher_4.png" width="24" height="24"> </td>
            <td > <strong>Aguardando a avaliação do COORDENADOR</strong></td>

            <td  align="center" > <img src="../images/skin/avaliador_3.png" width="24" height="24"> </td>
            <td > <strong>A avalição está EM ANDAMENTO</strong></td>

            <td  align="center" > <img src="../images/skin/finalizado_3.png" width="24" height="24"> </td>
            <td > <strong>Avaliação FINALIZADA</strong></td>

          </tr>

        </table>                    
      </g:form>
      <br/>                
    </div>


  </div>
</body>
</html>
